<?php 
class Xzsdsplus_Costpriceplus_Block_Groups_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
    
    public function __construct() {
        
        parent::__construct();

        $this->_objectId = 'entity_id';
        $this->_blockGroup = 'costpriceplus';
        $this->_controller = 'groups';
        
        $this->_updateButton('save', 'label', Mage::helper('costpriceplus')->__('Save Group'));
        $this->_updateButton('delete', 'label', Mage::helper('costpriceplus')->__('Delete Group'));
        
        $this->_addButton('saveandcontinue', array(
            'label'     => Mage::helper('adminhtml')->__('Save And Continue Edit'),
            'onclick'   => 'saveAndContinueEdit()',
            'class'     => 'save',
        ), -100);
 
        $this->_formScripts[] = "
            function saveAndContinueEdit(){
                editForm.submit($('edit_form').action+'back/edit/');
            }
            
            function alertData() {
                alert(groupProducts.toQueryString());
            }
        ";
    }
    
    public function getHeaderText() {
        if( Mage::registry('costpriceplus_groups_data') && Mage::registry('costpriceplus_groups_data')->getId() ) {
            return Mage::helper('costpriceplus')->__("Edit Group '%s'", $this->htmlEscape(Mage::registry('costpriceplus_groups_data')->getGroupName()));
        } else {
            return Mage::helper('costpriceplus')->__('Add Group');
        }
    }
}
